<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var operation = prompt("1.加法. 2.减法.");
        var one = prompt('第一个数字');
        var two = prompt('第二个数字');

        function cal(operation, one, two) {
            if (operation = '1') {
                return parseFloat(one) + parseFloat(two);
            } else if (operation = '2') {
                return parseFloat(one) - parseFloat(two);
            } else if (operation = '3') {
                return parseFloat(one) * parseFloat(two);
            } else {
                return parseFloat(one) / parseFloat(two);
            }
        }
    </script>
</body>

</html>